# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
import time
import huber 
from forecast_models import *
from accuracy import RMSE,MAE,MAPE,sMAPE,R_square
df = pd.read_csv('data.csv',index_col = 0)
df.fillna(method='pad', inplace=True)
import warnings
warnings.filterwarnings('ignore')
horizon = 1
sequence_length = 8
index = 'Power'
# In[]
# 存储过程

times = time.strftime('%Y-%m-%d-%H-%M',time.localtime(time.time()))
savepath = '预测结果保存'+'/'
filename = str(times)+ "预测值.csv"
generpath(savepath)
#%% SVR模型
model_index1 = 'SVR'
y_test_rel,y_svr_pre = lstm_model_huber(df,sequence_length = sequence_length,horizon = horizon)
mae_svr = MAE(y_test_rel,y_svr_pre)
rmse_svr = RMSE(y_test_rel,y_svr_pre)
mape_svr = sMAPE(y_test_rel,y_svr_pre)
print('svr的MAE为：'+str(mae_svr)) #"MAE:"
print('svr的RMSE为：'+str(rmse_svr)) #
print('svr的RMSE为：'+str(mape_svr)) #
print(R_square(y_test_rel,y_svr_pre))
print(MAPE(y_test_rel,y_svr_pre))
x=pd.DataFrame(y_svr_pre,columns=['svr'])
x.to_csv('ihho-huber-pre.csv')